<?php

namespace Controller\User;

abstract class Base extends \Controller\Base {

    protected $userId;

    protected $menuType = 'setting';

	public function actionBefore() {
		parent::actionBefore();
        $this->setCurrentMenuKey('My');
        $this->mustLogin();
        $userInfo = $this->currentUserInfo;
        $this->userId = $userInfo['UserId'];
        $breedId = $userInfo['BreedId'];
        $userInfo['breed'] = \Business\Breed::instance()->getNameById($breedId);
        if (!$userInfo['Username']) {
            \Lib\Util\Comm::redirect('/setting.html');
        }
        // 获取粉丝和关注数量
        $fansCount = \Business\User::instance()->getUserFansNumber($userInfo['UserId']);
        $followCount = \Business\User::instance()->getUserFollowNumber($userInfo['UserId']);
        $this->assign('userInfo', $userInfo);
        $this->assign('fansCount', $fansCount);
        $this->assign('followCount', $followCount);
        $this->assign('menuType', $this->menuType);
        // 获取用户未读消息个数
        $helloCount = \Business\User::instance()->getUserNotReadHelloCount($this->userId);
        $this->assign('helloCount', $helloCount);
	}
}